<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>

<s:url value="/images" var="imgPath"/>
<!-- 月历 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css" />
<script language="javascript">
	$().ready( function() {
		$('#startDate').datepick({minDate: null, showOn: 'both', 
	    	buttonImageOnly: true, buttonImage: '${imgPath}/calendar.gif',numberOfMonths:2,dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		$('#endDate').datepick({minDate: new Date(), showOn: 'both', 
		   	  buttonImageOnly: true, buttonImage: '${imgPath}/calendar.gif',numberOfMonths:2,beforeShow:customRange,dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		function customRange (){
			var startDt = $('#startDate').val(); //起始日
			var endDt = new Date(parseInt(startDt.substring(0,4),10),parseInt(startDt.substring(5,7),10)-1,parseInt(startDt.substring(8,10),10)); //結束日
			return {minDate:endDt}; 
		}
	});	

</script>
<s:actionerror />
<s:actionmessage />
<s:fielderror />

<s:form action="search.do" method="post" id="formObj">
	<s:hidden name="currentPage" />
	<h1>满额购条件设定</h1>
	<div class="f-link">
		<a href="add.do">新增</a>
		<a href="#" onclick="document.formObj.submit();">搜寻</a>
	</div>
	<div class="data-form">
	<b>期间：</b> 
	<input type="text" name="startDate" id="startDate" value="${startDate}" size="10" readonly="readonly"/>	
	<select id="startTime" name="startTime">
					
      	<c-rt:forEach begin="1" end="24" var="t1">
	      	<c:if test="${t1<10}">
				<c:set value="0${t1}:00" var="sTime"></c:set>
			</c:if>
			<c:if test="${t1>=10}">
				<c:set value="${t1}:00" var="sTime"></c:set>
			</c:if>
			<option value="${sTime}" <c:if test="${sTime==startTime }">selected</c:if>>${sTime}</option>
			
		</c-rt:forEach>
   </select> ~ 
	<input type="text" name="endDate" id="endDate" value="${endDate}" size="10" readonly="readonly"/>
	<select id="endTime" name="endTime">			
      	<c-rt:forEach begin="1" end="24" var="t2">
			<c:if test="${t2<10}">
			<c:set value="0${t2}:59" var="eTime"></c:set>
			</c:if>
			<c:if test="${t2>=10}">
			<c:set value="${t2}:59" var="eTime"></c:set>
			</c:if>
			
			<option value="${eTime}" <c:if test="${eTime==endTime }">selected</c:if>>${eTime}</option>
		</c-rt:forEach>
   </select>
	</div>
</s:form>
<br />
<br />
<br />
<s:if test="addPurchaseSettingList.size > 0">
	<yaodian100:pageutil pagerObj="${pager}" link="search.do"/>
	<table width="600">
		<thead class="tb-1" >
			<tr>
				<th>#</th>
				<th>满额购加购金额</th>
				<th>起</th>
				<th>迄</th>
			</tr>
		</thead>
		<tbody class="tb-1" >
			<c:forEach items="${addPurchaseSettingList}" var="addPurchaseSetting" varStatus="rows_index">
				<tr class="${rows_index.count % 2 == 0 ? 'bg-yl' : ''}">
					
					<td><a href="modify.do?settingId=${addPurchaseSetting.settingId}" />${addPurchaseSetting.settingId}</a></td>
					<td><fmt:formatNumber value="${addPurchaseSetting.basePrice}" pattern="#######0.0"/></td>					
					<td><fmt:formatDate value="${addPurchaseSetting.startDate}" pattern="yyyy-MM-dd HH:mm"/></td>
					<td><fmt:formatDate value="${addPurchaseSetting.endDate}" pattern="yyyy-MM-dd HH:mm"/></td>					
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<yaodian100:pageutil pagerObj="${pager}" link="search.do"/>
</s:if>
